* {
    /* 初始化 取消页面的内外边距 */
    padding: 0;
    margin: 0;
}

body {
    /* 弹性布局 让页面元素垂直+水平居中 */
    display: flex;
    justify-content: center;
    align-items: center;
    /* 让页面始终占浏览器总高 */
    width: 100vw;
    height: 100vh;
    background-color: #000;
    /* 视距 增加盒子的立体感 */
    perspective: 1000px;
}

.container {
    /* 相对定位 */
    position: relative;
    width: 150px;
    height: 150px;
    /* 让子元素保留其3D位置 */
    transform-style: preserve-3d;
    /* 动画 名称 时长 linear 是匀速运动 infinite是无限次播放 */
    animation: rotate 5s linear infinite;
}

/* 魔方每一面的盒子容器 */
.container div {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #fff;
    transition: all 1s;
}
/* 外层面 */
.container div:nth-child(1) {
    transform: translateZ(75px);
    background: url("../images/1.jpg") white no-repeat center/cover;
}

.container:hover div:nth-child(1) {
    transform: translateZ(200px);
}

.container div:nth-child(2) {
    transform: rotateX(-180deg) translateZ(75px);
    background: url("../images/2.jpg") white no-repeat center/cover;
}

.container:hover div:nth-child(2) {
    transform: rotateX(-180deg) translateZ(200px);
}

.container div:nth-child(3) {
    transform: rotateX(90deg) translateZ(75px);
    background: url("../images/3.jpg") white no-repeat center/cover;
}

.container:hover div:nth-child(3) {
    transform: rotateX(90deg) translateZ(200px);
}

.container div:nth-child(4) {
    transform: rotateX(-90deg) translateZ(75px);
    background: url("../images/4.jpg") white no-repeat center/cover;
}

.container:hover div:nth-child(4) {
    transform: rotateX(-90deg) translateZ(200px);
}

.container div:nth-child(5) {
    transform: rotateY(90deg) translateZ(75px);
    background: url("../images/5.jpg") white no-repeat center/cover;
}

.container:hover div:nth-child(5) {
    transform: rotateY(90deg) translateZ(200px);
}

.container div:nth-child(6) {
    transform: rotateY(-90deg) translateZ(75px);
    background: url("../images/6.jpg") white no-repeat center/cover;
}

.container:hover div:nth-child(6) {
    transform: rotateY(-90deg) translateZ(200px);
}

/* 从这里开始设置的方块每一面和上面是一样的，这里的每一面不存在 hover 效果 */

.container div:nth-child(7) {
    transform: translateZ(75px);
    background: url("../images/1.jpg") white no-repeat center/cover;
}

.container div:nth-child(8) {
    transform: rotateX(-180deg) translateZ(75px);
    background: url("../images/2.jpg") white no-repeat center/cover;
}

.container div:nth-child(9) {
    transform: rotateX(90deg) translateZ(75px);
    background: url("../images/3.jpg") white no-repeat center/cover;
}

.container div:nth-child(10) {
    transform: rotateX(-90deg) translateZ(75px);
    background: url("../images/4.jpg") white no-repeat center/cover;
}

.container div:nth-child(11) {
    transform: rotateY(90deg) translateZ(75px);
    background: url("../images/5.jpg") white no-repeat center/cover;
}

.container div:nth-child(12) {
    transform: rotateY(-90deg) translateZ(75px);
    background: url("../images/6.jpg") white no-repeat center/cover;
}

@keyframes rotate {
    0% {
        transform: rotateY(0) rotateX(0);
    }

    100% {
        transform: rotateY(360deg) rotateX(360deg);
    }
}
